package com.andy.module.util;

import android.text.TextUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 描述:正则表达式验证方法
 */
public class RegUtil {
    //检测正确的身份证号码
    public static boolean checkRightIDCard(String idcardStr) {
        if (TextUtils.isEmpty(idcardStr)) {
            return false;
        }
        Pattern p = Pattern.compile("(^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{2}$)");
        Matcher m = p.matcher(idcardStr);
        return m.matches();
    }

    public static boolean checkAllChina(String userNameStr) {
        if (TextUtils.isEmpty(userNameStr)) {
            return false;
        }
        Pattern p = Pattern.compile("^[\\u4e00-\\u9fa5]+$");
        Matcher m = p.matcher(userNameStr);
        return m.matches();
    }

}
